<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商品管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addGoods()" shiro:hasPermission="lucky:goods:add">
                    <i class="fa fa-plus"></i> 添加商品
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="lucky:blindbox:remove">
                    <i class="fa fa-remove"></i> 删除商品
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('lucky:goods:edit')}]];
        var removeFlag = [[${@permission.hasPermi('lucky:goods:remove')}]];
        var prefix = ctx + "lucky/boxGoods";
        var blindboxId = '';
        function addGoods() {
            $.modal.open("商品选择", prefix + "/selectGoods?blindboxId=" + blindboxId);
        }
        $(function() {
            blindboxId = [[${blindboxId}]]
            var options = {
                url: prefix + "/list/"+blindboxId,
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "商品管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'tGoods.goodsName',
                    title: '商品名称'
                },
                {
                    field: 'tGoods.goodsPic',
                    title: '商品图片',
                    formatter: function (value, row, index) {
                        return '<img src="' + value + '" width="80" height="50">';
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
              ]
            };
            $.table.init(options);
        });
        function refresh() {
            $.table.refresh();
        }
    </script>
</body>
</html>